from django.db import models

class Department(models.Model):
    name = models.CharField(max_length=100, unique=True)
    address = models.CharField(max_length=1000)

    def __unicode__(self):
        return self.name

class Employee(models.Model):
    name = models.CharField(max_length=10)
    passwd = models.CharField(max_length=100)
    sex = models.BooleanField()
    birthday = models.DateField()
    department = models.ForeignKey(Department)
    email = models.EmailField()

    def __unicode__(self):
        return self.name

class Project(models.Model):
    name = models.CharField(max_length=100, unique=True)
    memo = models.TextField()
    startdate = models.DateField()
    member = models.ManyToManyField(Employee)

    def __unicode__(self):
        return self.name

class Task(models.Model):
    name = models.CharField(max_length=100, unique=True)
    user = models.ForeignKey(Employee)
    project = models.ForeignKey(Project)
    plan_start_date = models.DateField()
    plan_finish_date = models.DateField(null=True)
    actual_start_date = models.DateField(null=True)
    actual_finish_date = models.DateField(null=True)
    task_info = models.CharField(max_length=1000)

    def __unicode__(self):
        return u'%s@%s' %(self.name, self.user)

